import QRCode from 'qrcode.react';

const QRCodeComponent = ({
  value = '',
  size = 256,
  logo = '',
  logoWidth = size*0.15,
  logoHeight = size*0.15,
  fgColor = '#000000', // 默认前景色为黑色
  bgColor = '#ffffff'  // 默认背景色为白色
}) => {
  return (
    <div className="flex justify-center items-center p-4 bg-white border border-gray-200 rounded-lg shadow-md">
      <QRCode
        value={value}
        size={size}
        fgColor={fgColor}
        bgColor={bgColor}
        imageSettings={{
          src: logo,
          height: logoHeight,
          width: logoWidth,
          excavate: true, // 这个属性确保在logo区域二维码会被清除，避免影响扫描
        }}
      />
    </div>
  );
};

export default QRCodeComponent;
